Repository navigation
resizable: Expose whether a handle is being dragged - #4039
Conversation
Add `ResizableState::is_resizing`, which reports whether one of the group's resize handles is being dragged. `ResizablePanelEvent::Resized` only arrives once a drag ends, so render code had no way to tell that a drag is in progress. Closes #4037
|
💡 Small read-only getter; looks right to me, but it adds public API, so a maintainer will decide. Reviewed head API review
Ran
|
|
✅ API accepted: Remaining before merge: please reset the flag in |
clear() now resets the flag, and a drag stopped with stop_active_drag is ended on the next frame, as a mouse up would, so is_resizing() cannot stay true after the drag ends.
|
Thanks! Updated in ed31dc8:
New tests: |
|
✅ LGTM: the requested reset is in; Reviewed head ed31dc8. |
Closes longbridge#4037 ## Description Adds `ResizableState::is_resizing()`, so render code can tell a handle is being dragged (`ResizablePanelEvent::Resized` only fires once the drag ends). `resizing_panel_ix` already tracks this; the getter only exposes it. This touches `gpui-base` because the issue asks for exactly this Base-layer accessor. One thing the getter makes visible: `resizing_panel_ix` is only cleared on a mouse up the group paints and in `resize_panel`, so it stays set after `cx.stop_active_drag` cancels a drag or after `clear()` mid-drag, until the next mouse up. That's existing behaviour and I left it alone here; happy to follow up if you'd like `clear()` or a cancel path to reset it. ## Public API ### gpui-base - `ResizableState::is_resizing(&self) -> bool`: whether one of the group's resize handles is being dragged right now. ## How to Test - The existing `dragging_the_handle_resizes_and_emits_once` test now also checks `is_resizing()` before the drag, during it and after the release. It fails if the getter returns a constant `true` or `false`. - `cargo test -p gpui-base` (1768 lib tests plus the other targets), `cargo clippy -p gpui-base --all-targets -- -D warnings`, `rustfmt --check` on the file. ## Checklist - [x] I have read the [CONTRIBUTING](../CONTRIBUTING.md) document and followed the guidelines. - [x] Reviewed the changes in this PR and confirmed AI generated code (If any) is accurate. - [ ] Passed `cargo run` for story tests related to the changes. - [ ] Tested macOS, Windows and Linux platforms performance (if the change is platform-specific) The method and test in this PR were written with AI assistance (Claude).
Closes #4037
Description
Adds
ResizableState::is_resizing(), so render code can tell a handle is being dragged (ResizablePanelEvent::Resizedonly fires once the drag ends).resizing_panel_ixalready tracks this; the getter only exposes it. This touchesgpui-basebecause the issue asks for exactly this Base-layer accessor.One thing the getter makes visible:
resizing_panel_ixis only cleared on a mouse up the group paints and inresize_panel, so it stays set aftercx.stop_active_dragcancels a drag or afterclear()mid-drag, until the next mouse up. That's existing behaviour and I left it alone here; happy to follow up if you'd likeclear()or a cancel path to reset it.Public API
gpui-base
ResizableState::is_resizing(&self) -> bool: whether one of the group's resize handles is being dragged right now.How to Test
dragging_the_handle_resizes_and_emits_oncetest now also checksis_resizing()before the drag, during it and after the release. It fails if the getter returns a constanttrueorfalse.cargo test -p gpui-base(1768 lib tests plus the other targets),cargo clippy -p gpui-base --all-targets -- -D warnings,rustfmt --checkon the file.Checklist
cargo runfor story tests related to the changes.The method and test in this PR were written with AI assistance (Claude).